load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")

package(default_visibility = ["//visibility:public"])

licenses(["notice"])  # Apache License 2.0

go_library(
    name = "traceparser",
    importpath = "github.com/google/schedviz/traceparser/traceparser",

    srcs = [
        "event_set_builder.go",
        "eventformat.go",
        "formatparser.go",
        "path.go",
        "ringbuffer.go",
        "trace_parser.go",
        "traceevent.go",
    ],
    deps = [
        "//analysis:event_loaders_go_proto",
        "//tracedata:clipping",
        "//tracedata:schedviz_events_go_proto",
        "//util",
        "@com_github_golang_protobuf//proto:go_default_library",
    ],
)

go_test(
    name = "formatparser_test",
    size = "small",
    srcs = ["formatparser_test.go"],
    embed = [":traceparser"],
    deps = [
        "@com_github_google_go-cmp//cmp:go_default_library",
        "@com_github_google_go-cmp//cmp/cmpopts:go_default_library",
    ],
)

go_test(
    name = "traceparser_test",
    size = "small",
    srcs = [
        "event_set_builder_test.go",
        "trace_parser_test.go",
    ],
    data = [
        "testdata/input/cpu0",
        "testdata/input/cpu0-32",
        "testdata/output/trace.gob",
        "testdata/output/trace-32.gob",
    ],
    embed = [":traceparser"],
    deps = [
        "//testhelpers",
        "//tracedata:schedviz_events_go_proto",
        "@com_github_golang_protobuf//proto:go_default_library",
        "@com_github_google_go-cmp//cmp:go_default_library",
        "@com_github_google_go-cmp//cmp/cmpopts:go_default_library",
    ],
)
